package edu.nctu.csie.jichang.database.model.cell;



public class DBTableHeader extends AbstractContainer<ColumnInfo>{

	
	private NameMap primaryKey;
	private NameMap unique;
	private NameMap index;
	private NameMap reference;
	
	public DBTableHeader() {
		this("".intern());
	}
	
	public DBTableHeader(String pContent) {
		super(pContent);
	}
	
	public void addTableHead(ColumnInfo pColumnInfo){
		container.put(pColumnInfo.getName(), pColumnInfo);
	}
	public void addTableHead(String pColumnName, ColumnInfo pType) {
		container.put(pColumnName, pType);
	}
	public ColumnInfo[] getColumns(){
		return getChildren().values().toArray(new ColumnInfo[0]);
	}
	public String[] getColumnNames(){
		return container.keySet().toArray(new String[0]);
	}
	public ColumnInfo getColumnType(String pName){
		return (ColumnInfo)container.get(pName);
	}
	public boolean hasColumn(String pName){
		return hasChild(pName);
	}
	
	@Override
	public String toString() {
		StringBuffer tOutput = new StringBuffer();
		tOutput.append("[");
		for(String s: container.keySet().toArray(new String[0])){
			tOutput.append(s).append(":").append(container.get(s)).append(";");
		}
		tOutput.deleteCharAt(tOutput.length()-1);
		tOutput.append("]");
		return tOutput.toString();
	}

	public NameMap getPrimaryKey() {
		return primaryKey;
	}
	public void setPrimaryKey(NameMap primaryKey) {
		this.primaryKey = primaryKey;
	}
	public NameMap getUnique() {
		return unique;
	}
	public void setUnique(NameMap unique) {
		this.unique = unique;
	}
	public NameMap getIndex() {
		return index;
	}
	public void setIndex(NameMap index) {
		this.index = index;
	}
	public NameMap getReference() {
		return reference;
	}
	public void setReference(NameMap reference) {
		this.reference = reference;
	}
}